package com.lanou.shunke.admin.service;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanou.shunke.admin.entity.*;
import com.lanou.shunke.admin.mapper.ArticleMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {

    @Autowired
    private ArticleMapper mapper;

    /*查看所有文章*/
    public List<AllArticle> selectAllArticle(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List list = mapper.selectAllArticle();
        return list;
    }

    /*按照文章分类查询*/
    public List<Article> selectArticelByType(int pageNum, int pageSize, int type) {
        PageHelper.startPage(pageNum, pageSize);
        List list = mapper.selectByType(type);
        return list;
    }

    /*查看封禁文章*/
    public List selectReportArticle(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List list = mapper.selectReport();
        return list;
    }

    public List<Article> selectBan(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return mapper.selectBan();
    }

    public void banByUid(String articleId) {
        mapper.banByUid(articleId);
    }

    public void UnsealingByArtID(String articleId) {
        mapper.UnsealingByArtId(articleId);
    }

    public List<ArticleClassification> selectType() {
        return mapper.selectType();
    }

    public void updateType(int typeId, String typeName) {
        mapper.updateTypeById(typeId, typeName);
        mapper.updateType(typeId,typeName);
    }

    public List<ArticleComment> selectComment(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return mapper.selectComment();
    }

    public void delComment(String articleCommentId) {
        mapper.delComment(articleCommentId);
    }

    public List<AllArticle> showArticle(String articleId) {
        return mapper.selectArticle(articleId);
    }

    public List<ArticleReply> showReply() {
        return mapper.showReply();
    }

    public void delReplyById(long articleReplyId) {
        mapper.delReplyById(articleReplyId);
    }
}
